<?php
/**
 * Tests for Feed model
 *
 * PHP version 5
 *
 * @package    TV
 * @subpackage Tests
 * @author     Mike Bevz <mike.bevz@data2people.com>
 * @copyright  2007-2008 (c) Mike Bevz
 * @version    SVN: $Id:  $
 *
 *
 */

require_once dirname(__FILE__).'/../testsConfig.php';
require_once 'PHPUnit/Framework.php';

class FeedTests extends PHPUnit_Framework_TestCase
{
    /**
     * Model class
     *
     * @var Feed
     */
    private $_model;
    
    
    protected function setUp()
    {
        $this->_model = new Feed();
    }

    protected function tearDown()
    {
      unset($this->_model);
    }
    
    public function testSetGetProperties()
    {
        $expected = 'testWord';
        $this->_model->title = $expected;
        $this->assertEquals($expected, $this->_model->title);
        
        $expected = 'test description';
        $this->_model->description = $expected;
        $this->assertEquals($expected, $this->_model->description);
        
        $expected = 'test description';
        $this->_model->description = $expected;
        $this->assertEquals($expected, $this->_model->description);
        
        $expected = 'http://link.example.com';
        $this->_model->link = $expected;
        $this->assertEquals($expected, $this->_model->link);
        
        $expected = '1922-12-01 10:10:10';
        $this->_model->pubdate = $expected;
        $this->assertEquals($expected, $this->_model->pubdate);
        
        $expected = 'eb-us';
        $this->_model->language = $expected;
        $this->assertEquals($expected, $this->_model->language);
        
        $expected = 'top story';
        $this->_model->category = $expected;
        $this->assertEquals($expected, $this->_model->category);
         
    }
    
    /**
     * @expectedException TV_Model_Exception
     *
     */
    public function testGetByLinkAcceptsOnlyString()
    {
        $this->_model->getByLink(array());
    }
    
    public function testGetByLinkReturnFeedObject()
    {
        $link = 'some-link.dk';
        
        $feed = new Feed();
        $feed->link = $link;
        $feed->title = 'sometitle';
        $feed->save();
        
        $result = $this->_model->getByLink($link);
        $this->assertEquals('sometitle', $result[0]->title);
        $feed->delete();
    }
    
   
      
}